import React, {Component} from 'react';
import {View, Text, ScrollView, Image, Dimensions,TouchableOpacity} from 'react-native';

import ajax from '../../../src/utils/fetch'

const {width} = Dimensions.get('window');

import {GETRECOMENDLIST} from "../../../src/const/shareUri";

export default class Demo14Component extends Component {
  //let arr=[{name:'linqinghu'}]
  constructor(props) {
    super(props);
    this.state = {
      list: []
    }
  }

  componentDidMount() {
    this._getNewList();
  }

  render() {
    return (
        <View style={{flex: 1, backgroundColor: '#fff'}}>
          <View style={{
            flexDirection: 'row',
            height: 50,
            justifyContent: 'center',
            alignItems: 'center',
            backgroundColor: '#27b5ee',
          }}>
            <Text style={{
              color: 'white',
              fontSize: 20,
              textAlign: 'center'
            }}>图片列表</Text>
          </View>
          <ScrollView contentContainerStyle={{paddingVertical: 0}}>
            {
              this.state.list.map((item, index) =>
                  <View>
                    <Image style={{width: width, height: width * (392 / 694)}} source={{uri: item.recommendPagePic2}}>
                    </Image>
                  </View>
              )
            }
          </ScrollView>

          <TouchableOpacity activeOpacity={0.8}>
            <Text>回到顶部</Text>
          </TouchableOpacity>

        </View>
    )
  }

  _getNewList = () => {
    ajax.get(GETRECOMENDLIST, {}, res => {
      //alert(res.data.length);
      this.setState({list: res.data});
    });
  };
}